use system_all::system_service_client::SystemServiceClient;
use system_all::{LoginByAccountReq, LoginByMobileReq, GetUserListReq, CreateUserReq};

pub mod system_all {
    tonic::include_proto!("system.all");
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = SystemServiceClient::connect("http://[::1]:50051").await?;

    // 测试账号登录
    println!("=== Testing LoginByAccount ===");
    let request = tonic::Request::new(LoginByAccountReq {
        name: "admin".into(),
        password: "123456".into(),
    });
    let response = client.login_by_account(request).await?;
    println!("LoginByAccount RESPONSE={:?}", response);

    // 测试手机登录
    println!("\n=== Testing LoginByMobile ===");
    let request = tonic::Request::new(LoginByMobileReq {
        mobile: "13800138000".into(),
        code: "123456".into(),
    });
    let response = client.login_by_mobile(request).await?;
    println!("LoginByMobile RESPONSE={:?}", response);

    // 测试获取用户列表
    println!("\n=== Testing GetUserList ===");
    let request = tonic::Request::new(GetUserListReq {
        name: "".into(),
        page: 1,
        page_size: 10,
        status: 1,
    });
    let response = client.get_user_list(request).await?;
    println!("GetUserList RESPONSE={:?}", response);

    // 测试创建用户
    println!("\n=== Testing CreateUser ===");
    let request = tonic::Request::new(CreateUserReq {
        username: "newuser".into(),
        password: "newpass".into(),
        nickname: "New User".into(),
        email: "newuser@example.com".into(),
        mobile: "13900139000".into(),
    });
    let response = client.create_user(request).await?;
    println!("CreateUser RESPONSE={:?}", response);

    Ok(())
} 